package com.mall.controller;

import java.io.InputStream;
import java.net.URI;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Set;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import com.mall.bean.Goods;
import com.mall.bean.User;
import com.mall.service.IGoodsService;

@Controller
public class GoodsController {
	
	@Resource
	private IGoodsService goodsService;
	
	
	
	//展示图书图片
	@RequestMapping("showPhoto")
	public void showPhoto(HttpServletRequest request, HttpServletResponse response) throws Exception {

		if ("url1".equals(request.getParameter("requestName"))) {

			download(response, request.getParameter("url1"));
		} else if ("url2".equals(request.getParameter("requestName"))) {

			download(response, request.getParameter("url2"));
		} else if ("url3".equals(request.getParameter("requestName"))) {

			download(response, request.getParameter("url3"));
		} else if ("url4".equals(request.getParameter("requestName"))) {

			download(response, request.getParameter("url4"));
		} else if ("url5".equals(request.getParameter("requestName"))) {

			download(response, request.getParameter("url5"));
		} else if ("url6".equals(request.getParameter("requestName"))) {

			download(response, request.getParameter("url6"));
		} else if ("url7".equals(request.getParameter("requestName"))) {

			download(response, request.getParameter("url7"));
		} else if ("url8".equals(request.getParameter("requestName"))) {

			download(response, request.getParameter("url8"));
		} else if ("url9".equals(request.getParameter("requestName"))) {

			download(response, request.getParameter("url9"));
		} 
	}
	
	// 从hdfs下载图片
		public void download(HttpServletResponse response, String newurl) throws Exception {
			// hdfs文件 地址
			// String file = "hdfs://iflytek002:9000";
			Configuration conf = new Configuration();
			// 构建FileSystem
			FileSystem fs = FileSystem.get(new URI(newurl), conf);
			// 读取文件
			FSDataInputStream is = fs.open(new Path(newurl));
			// 响应到页面			
			ServletOutputStream output = response.getOutputStream();
			// 保存到本地 最后 关闭输入输出流
			IOUtils.copyBytes(is, output, conf);
		}
		
		@RequestMapping("publish_book")
		public String publish(@RequestParam("url") MultipartFile[] file, HttpSession session,Goods goods,Model model)
				throws Exception {
			User user = (User) session.getAttribute("user");
			
			// int length1 = file.length-1;
			// String[] arrary = new String[length1];
			List<String> arrary = new ArrayList<>();
			Date time = new Date();
			SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String nowdata = ft.format(time);
			String[] list = nowdata.split(" ");
			String data = list[0] + "-" + list[1].split(":")[0] + list[1].split(":")[1] + list[1].split(":")[2];
			
			System.out.println("开始循环咯" + data);
			
			
			//生成不重复的随机set集合
			for (int i = 0; i < file.length; i++) {
				int n =1;
				Set set = new HashSet();
				Random random=new Random();
				while (set.size()<n) {
					 set.add(random.nextInt(100000000));
				}
				Iterator it = set.iterator();
				while(it.hasNext()) {
					Object number = it.next();
				System.out.println("开始循环咯");
				String url = file[i].getOriginalFilename();
				String type = file[i].getContentType().split("/")[1];
				String newurl = null;
				if ("jpeg".equals(type) || "jpg".equals(type) || "png".equals(type)||"bmp".equals(type) || "mp4".equals(type)) {
					newurl = "hdfs://iflytek002:9000/photo/" + user.getUsername() + "-" + data + "-" +number + "."+type;
					System.out.println("newurl：" + newurl);
					arrary.add(newurl);
					System.out.println("array：" + arrary.get(0));
					if (i == 0) {						
						goods.setGoods_url1(arrary.get(0));
					} else if (i == 1) {
						goods.setGoods_url2(arrary.get(1));
					} else if (i == 2) {
						goods.setGoods_url3(arrary.get(2));
					} else if (i == 3) {
						goods.setGoods_url4(arrary.get(3));
					} else if (i == 4) {
						goods.setGoods_url5(arrary.get(4));
					} else if (i == 5) {
						goods.setGoods_url6(arrary.get(5));
					} else if (i == 6) {
						goods.setGoods_url7(arrary.get(6));
					} else if (i == 7) {
						goods.setGoods_url8(arrary.get(7));
					} else if (i == 8) {
						goods.setGoods_url9(arrary.get(8));
					}
				}
			}
			}
			System.out.println("第一次上传：" + arrary + "长度：" + arrary.size());
			upload(file, arrary);
			goods.setUser_id(user.getUser_id());
			goods.setBelong("闲置");
			goods.setGoods("图书");
			goods.setDate(nowdata);
			goodsService.addGoods(goods);
			System.out.println("上传成功；" + arrary + "长度：" + arrary.size());
			model.addAttribute("user", user);
			return "index-2";
		}
		
		private void upload(@RequestParam("url") MultipartFile[] file, List<String> url) throws Exception {
			Configuration conf = new Configuration();
			// int length = file.length;
			for (int i = 0; i < file.length; i++) {
				InputStream in = file[i].getInputStream();
				URI hfdfsfile = new URI("hdfs://iflytek002:9000");
				conf.set("fs.defaultFS", "hdfs://iflytek002:9000");
				conf.set("fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem");
				/* conf.set("fs.file.impl", "org.apache.hadoop.fs.LocalFileSystem"); */
				FileSystem fs = FileSystem.get(hfdfsfile, conf, "root");
				Path path = new Path(url.get(i));
				FSDataOutputStream out = fs.create(path);
				IOUtils.copyBytes(in, out, conf);
				fs.close();
				in.close();
			}
		}
		
		
		@RequestMapping("publish-book-recycle")
		public String addAutoGoods(@RequestParam("url") MultipartFile[] file, HttpSession session,Goods goods,Model model) throws Exception {
			User user = (User) session.getAttribute("user");
				
			// int length1 = file.length-1;
			// String[] arrary = new String[length1];
			List<String> arrary = new ArrayList<>();
			Date time = new Date();
			SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String nowdata = ft.format(time);
			String[] list = nowdata.split(" ");
			String data = list[0] + "-" + list[1].split(":")[0] + list[1].split(":")[1] + list[1].split(":")[2];
			
			System.out.println("开始循环咯" + data);
			//生成不重复的随机set集合
			
			
			for (int i = 0; i < file.length; i++) {
				int n =1;
				Set set = new HashSet();
				Random random=new Random();
				while (set.size()<n) {
					 set.add(random.nextInt(100000000));
				}
				Iterator it = set.iterator();
				while(it.hasNext()) {
					Object number = it.next();
				System.out.println("开始循环咯");
				String url = file[i].getOriginalFilename();
				String type = file[i].getContentType().split("/")[1];
				String newurl = null;
				if ("jpeg".equals(type) || "jpg".equals(type) || "png".equals(type)||"bmp".equals(type) || "mp4".equals(type)) {
					newurl = "hdfs://iflytek002:9000/photo/" + user.getUsername() + "-" + data + "-" +number + "."+type;
					System.out.println("newurl：" + newurl);
					arrary.add(newurl);
					System.out.println("array：" + arrary.get(0));
					if (i == 0) {						
						goods.setGoods_url1(arrary.get(0));
					} else if (i == 1) {
						goods.setGoods_url2(arrary.get(1));
					} else if (i == 2) {
						goods.setGoods_url3(arrary.get(2));
					} else if (i == 3) {
						goods.setGoods_url4(arrary.get(3));
					} else if (i == 4) {
						goods.setGoods_url5(arrary.get(4));
					} else if (i == 5) {
						goods.setGoods_url6(arrary.get(5));
					} else if (i == 6) {
						goods.setGoods_url7(arrary.get(6));
					} else if (i == 7) {
						goods.setGoods_url8(arrary.get(7));
					} else if (i == 8) {
						goods.setGoods_url9(arrary.get(8));
					}
				}
			}
			}
			System.out.println("第一次上传：" + arrary + "长度：" + arrary.size());
			upload(file, arrary);
			goods.setUser_id(user.getUser_id());
			goods.setGoods("图书");
			goods.setDate(nowdata);
			goodsService.addAutoGoods(goods);
			model.addAttribute("user", user);
			return "index-2";
		}
		
		
		//发布手机
		@RequestMapping("publish_phone")
		public String phone(@RequestParam("url") MultipartFile[] file, HttpSession session,Goods goods,Model model) throws Exception {
			
			User user = (User) session.getAttribute("user");
			
			// int length1 = file.length-1;
			// String[] arrary = new String[length1];
			List<String> arrary = new ArrayList<>();
			Date time = new Date();
			SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String nowdata = ft.format(time);
			String[] list = nowdata.split(" ");
			String data = list[0] + "-" + list[1].split(":")[0] + list[1].split(":")[1] + list[1].split(":")[2];
			
			System.out.println("开始循环咯" + data);
			//生成不重复的随机set集合
			
			
			for (int i = 0; i < file.length; i++) {
				int n =1;
				Set set = new HashSet();
				Random random=new Random();
				while (set.size()<n) {
					 set.add(random.nextInt(100000000));
				}
				Iterator it = set.iterator();
				while(it.hasNext()) {
					Object number = it.next();
				System.out.println("开始循环咯");
				String url = file[i].getOriginalFilename();
				String type = file[i].getContentType().split("/")[1];
				String newurl = null;
				if ("jpeg".equals(type) || "jpg".equals(type) || "png".equals(type)||"bmp".equals(type) || "mp4".equals(type)) {
					newurl = "hdfs://iflytek002:9000/photo/" + user.getUsername() + "-" + data + "-" +number + "."+type;
					System.out.println("newurl：" + newurl);
					arrary.add(newurl);
					System.out.println("array：" + arrary.get(0));
					if (i == 0) {						
						goods.setGoods_url1(arrary.get(0));
					} else if (i == 1) {
						goods.setGoods_url2(arrary.get(1));
					} else if (i == 2) {
						goods.setGoods_url3(arrary.get(2));
					} else if (i == 3) {
						goods.setGoods_url4(arrary.get(3));
					} else if (i == 4) {
						goods.setGoods_url5(arrary.get(4));
					} else if (i == 5) {
						goods.setGoods_url6(arrary.get(5));
					} else if (i == 6) {
						goods.setGoods_url7(arrary.get(6));
					} else if (i == 7) {
						goods.setGoods_url8(arrary.get(7));
					} else if (i == 8) {
						goods.setGoods_url9(arrary.get(8));
					}
				}
			}
			}
			System.out.println("第一次上传：" + arrary + "长度：" + arrary.size());
			upload(file, arrary);
			goods.setUser_id(user.getUser_id());
			goods.setBelong("闲置");
			goods.setGoods("手机");
			goods.setDate(nowdata);
			goodsService.addGoods(goods);
			model.addAttribute("user", user);
			return "index-2";
		}
		
		//发布至平台手机
		@RequestMapping("publish-phone-recycle")
		public String phone2(@RequestParam("url") MultipartFile[] file, HttpSession session,Goods goods,Model model) throws Exception {
			
			User user = (User) session.getAttribute("user");
			
			// int length1 = file.length-1;
			// String[] arrary = new String[length1];
			List<String> arrary = new ArrayList<>();
			Date time = new Date();
			SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String nowdata = ft.format(time);
			String[] list = nowdata.split(" ");
			String data = list[0] + "-" + list[1].split(":")[0] + list[1].split(":")[1] + list[1].split(":")[2];
			
			System.out.println("开始循环咯" + data);
			//生成不重复的随机set集合
			
			
			for (int i = 0; i < file.length; i++) {
				int n =1;
				Set set = new HashSet();
				Random random=new Random();
				while (set.size()<n) {
					 set.add(random.nextInt(100000000));
				}
				Iterator it = set.iterator();
				while(it.hasNext()) {
					Object number = it.next();
				System.out.println("开始循环咯");
				String url = file[i].getOriginalFilename();
				String type = file[i].getContentType().split("/")[1];
				String newurl = null;
				if ("jpeg".equals(type) || "jpg".equals(type) || "png".equals(type)||"bmp".equals(type) || "mp4".equals(type)) {
					newurl = "hdfs://iflytek002:9000/photo/" + user.getUsername() + "-" + data + "-" +number + "."+type;
					System.out.println("newurl：" + newurl);
					arrary.add(newurl);
					System.out.println("array：" + arrary.get(0));
					if (i == 0) {						
						goods.setGoods_url1(arrary.get(0));
					} else if (i == 1) {
						goods.setGoods_url2(arrary.get(1));
					} else if (i == 2) {
						goods.setGoods_url3(arrary.get(2));
					} else if (i == 3) {
						goods.setGoods_url4(arrary.get(3));
					} else if (i == 4) {
						goods.setGoods_url5(arrary.get(4));
					} else if (i == 5) {
						goods.setGoods_url6(arrary.get(5));
					} else if (i == 6) {
						goods.setGoods_url7(arrary.get(6));
					} else if (i == 7) {
						goods.setGoods_url8(arrary.get(7));
					} else if (i == 8) {
						goods.setGoods_url9(arrary.get(8));
					}
				}
			}
			}
			System.out.println("第一次上传：" + arrary + "长度：" + arrary.size());
			upload(file, arrary);
			goods.setUser_id(user.getUser_id());
			goods.setGoods("手机");
			goods.setDate(nowdata);
			goodsService.addAutoGoods(goods);
			model.addAttribute("user", user);
			return "index-2";
		}
		
		//发布衣服
		@RequestMapping("publish_clothing")
		public String clothing(@RequestParam("url") MultipartFile[] file, HttpSession session,Goods goods,Model model) throws Exception {
			
			User user = (User) session.getAttribute("user");
			
			// int length1 = file.length-1;
			// String[] arrary = new String[length1];
			List<String> arrary = new ArrayList<>();
			Date time = new Date();
			SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String nowdata = ft.format(time);
			String[] list = nowdata.split(" ");
			String data = list[0] + "-" + list[1].split(":")[0] + list[1].split(":")[1] + list[1].split(":")[2];
			
			System.out.println("开始循环咯" + data);
			//生成不重复的随机set集合
			
			
			for (int i = 0; i < file.length; i++) {
				int n =1;
				Set set = new HashSet();
				Random random=new Random();
				while (set.size()<n) {
					 set.add(random.nextInt(100000000));
				}
				Iterator it = set.iterator();
				while(it.hasNext()) {
					Object number = it.next();
				System.out.println("开始循环咯");
				String url = file[i].getOriginalFilename();
				String type = file[i].getContentType().split("/")[1];
				String newurl = null;
				if ("jpeg".equals(type) || "jpg".equals(type) || "png".equals(type)||"bmp".equals(type) || "mp4".equals(type)) {
					newurl = "hdfs://iflytek002:9000/photo/" + user.getUsername() + "-" + data + "-" +number + "."+type;
					System.out.println("newurl：" + newurl);
					arrary.add(newurl);
					System.out.println("array：" + arrary.get(0));
					if (i == 0) {						
						goods.setGoods_url1(arrary.get(0));
					} else if (i == 1) {
						goods.setGoods_url2(arrary.get(1));
					} else if (i == 2) {
						goods.setGoods_url3(arrary.get(2));
					} else if (i == 3) {
						goods.setGoods_url4(arrary.get(3));
					} else if (i == 4) {
						goods.setGoods_url5(arrary.get(4));
					} else if (i == 5) {
						goods.setGoods_url6(arrary.get(5));
					} else if (i == 6) {
						goods.setGoods_url7(arrary.get(6));
					} else if (i == 7) {
						goods.setGoods_url8(arrary.get(7));
					} else if (i == 8) {
						goods.setGoods_url9(arrary.get(8));
					}
				}
			}
			}
			System.out.println("第一次上传：" + arrary + "长度：" + arrary.size());
			upload(file, arrary);
			goods.setUser_id(user.getUser_id());
			goods.setBelong("闲置");
			goods.setGoods("服装");
			goods.setDate(nowdata);
			goodsService.addGoods(goods);
			model.addAttribute("user", user);
			return "index-2";
		}
		
		//发布至平台的衣服
		@RequestMapping("publish-clothing-recycle")
		public String clothing2(@RequestParam("url") MultipartFile[] file, HttpSession session,Goods goods,Model model) throws Exception {
			
			User user = (User) session.getAttribute("user");
			
			// int length1 = file.length-1;
			// String[] arrary = new String[length1];
			List<String> arrary = new ArrayList<>();
			Date time = new Date();
			SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String nowdata = ft.format(time);
			String[] list = nowdata.split(" ");
			String data = list[0] + "-" + list[1].split(":")[0] + list[1].split(":")[1] + list[1].split(":")[2];
			
			System.out.println("开始循环咯" + data);
			//生成不重复的随机set集合
			
			
			for (int i = 0; i < file.length; i++) {
				int n =1;
				Set set = new HashSet();
				Random random=new Random();
				while (set.size()<n) {
					 set.add(random.nextInt(100000000));
				}
				Iterator it = set.iterator();
				while(it.hasNext()) {
					Object number = it.next();
				System.out.println("开始循环咯");
				String url = file[i].getOriginalFilename();
				String type = file[i].getContentType().split("/")[1];
				String newurl = null;
				if ("jpeg".equals(type) || "jpg".equals(type) || "png".equals(type)||"bmp".equals(type) || "mp4".equals(type)) {
					newurl = "hdfs://iflytek002:9000/photo/" + user.getUsername() + "-" + data + "-" +number + "."+type;
					System.out.println("newurl：" + newurl);
					arrary.add(newurl);
					System.out.println("array：" + arrary.get(0));
					if (i == 0) {						
						goods.setGoods_url1(arrary.get(0));
					} else if (i == 1) {
						goods.setGoods_url2(arrary.get(1));
					} else if (i == 2) {
						goods.setGoods_url3(arrary.get(2));
					} else if (i == 3) {
						goods.setGoods_url4(arrary.get(3));
					} else if (i == 4) {
						goods.setGoods_url5(arrary.get(4));
					} else if (i == 5) {
						goods.setGoods_url6(arrary.get(5));
					} else if (i == 6) {
						goods.setGoods_url7(arrary.get(6));
					} else if (i == 7) {
						goods.setGoods_url8(arrary.get(7));
					} else if (i == 8) {
						goods.setGoods_url9(arrary.get(8));
					}
				}
			}
			}
			System.out.println("第一次上传：" + arrary + "长度：" + arrary.size());
			upload(file, arrary);
			goods.setUser_id(user.getUser_id());
			goods.setGoods("服装");
			goods.setDate(nowdata);
			goodsService.addAutoGoods(goods);
			model.addAttribute("user", user);
			return "index-2";
		}
		
		//发布其它商品
		@RequestMapping("publish_other")
		public String other(@RequestParam("url") MultipartFile[] file, HttpSession session,Goods goods,Model model) throws Exception {
			
			User user = (User) session.getAttribute("user");
			
			// int length1 = file.length-1;
			// String[] arrary = new String[length1];
			List<String> arrary = new ArrayList<>();
			Date time = new Date();
			SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String nowdata = ft.format(time);
			String[] list = nowdata.split(" ");
			String data = list[0] + "-" + list[1].split(":")[0] + list[1].split(":")[1] + list[1].split(":")[2];
			
			System.out.println("开始循环咯" + data);
			//生成不重复的随机set集合
			
			
			for (int i = 0; i < file.length; i++) {
				int n =1;
				Set set = new HashSet();
				Random random=new Random();
				while (set.size()<n) {
					 set.add(random.nextInt(100000000));
				}
				Iterator it = set.iterator();
				while(it.hasNext()) {
					Object number = it.next();
				System.out.println("开始循环咯");
				String url = file[i].getOriginalFilename();
				String type = file[i].getContentType().split("/")[1];
				String newurl = null;
				if ("jpeg".equals(type) || "jpg".equals(type) || "png".equals(type)||"bmp".equals(type) || "mp4".equals(type)) {
					newurl = "hdfs://iflytek002:9000/photo/" + user.getUsername() + "-" + data + "-" +number + "."+type;
					System.out.println("newurl：" + newurl);
					arrary.add(newurl);
					System.out.println("array：" + arrary.get(0));
					if (i == 0) {						
						goods.setGoods_url1(arrary.get(0));
					} else if (i == 1) {
						goods.setGoods_url2(arrary.get(1));
					} else if (i == 2) {
						goods.setGoods_url3(arrary.get(2));
					} else if (i == 3) {
						goods.setGoods_url4(arrary.get(3));
					} else if (i == 4) {
						goods.setGoods_url5(arrary.get(4));
					} else if (i == 5) {
						goods.setGoods_url6(arrary.get(5));
					} else if (i == 6) {
						goods.setGoods_url7(arrary.get(6));
					} else if (i == 7) {
						goods.setGoods_url8(arrary.get(7));
					} else if (i == 8) {
						goods.setGoods_url9(arrary.get(8));
					}
				}
			}
			}
			System.out.println("第一次上传：" + arrary + "长度：" + arrary.size());
			upload(file, arrary);
			goods.setUser_id(user.getUser_id());
			goods.setBelong("闲置");
			goods.setGoods("其它");
			goods.setDate(nowdata);
			goodsService.addGoods(goods);
			model.addAttribute("user", user);
			return "index-2";
		}
		
		//发布至平台其它
		@RequestMapping("publish-other-recycle")
		public String other2(@RequestParam("url") MultipartFile[] file, HttpSession session,Goods goods,Model model) throws Exception {
			
			User user = (User) session.getAttribute("user");
			
			// int length1 = file.length-1;
			// String[] arrary = new String[length1];
			List<String> arrary = new ArrayList<>();
			Date time = new Date();
			SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String nowdata = ft.format(time);
			String[] list = nowdata.split(" ");
			String data = list[0] + "-" + list[1].split(":")[0] + list[1].split(":")[1] + list[1].split(":")[2];
			
			System.out.println("开始循环咯" + data);
			//生成不重复的随机set集合
			
			
			for (int i = 0; i < file.length; i++) {
				int n =1;
				Set set = new HashSet();
				Random random=new Random();
				while (set.size()<n) {
					 set.add(random.nextInt(100000000));
				}
				Iterator it = set.iterator();
				while(it.hasNext()) {
					Object number = it.next();
				System.out.println("开始循环咯");
				String url = file[i].getOriginalFilename();
				String type = file[i].getContentType().split("/")[1];
				String newurl = null;
				if ("jpeg".equals(type) || "jpg".equals(type) || "png".equals(type)||"bmp".equals(type) || "mp4".equals(type)) {
					newurl = "hdfs://iflytek002:9000/photo/" + user.getUsername() + "-" + data + "-" +number + "."+type;
					System.out.println("newurl：" + newurl);
					arrary.add(newurl);
					System.out.println("array：" + arrary.get(0));
					if (i == 0) {						
						goods.setGoods_url1(arrary.get(0));
					} else if (i == 1) {
						goods.setGoods_url2(arrary.get(1));
					} else if (i == 2) {
						goods.setGoods_url3(arrary.get(2));
					} else if (i == 3) {
						goods.setGoods_url4(arrary.get(3));
					} else if (i == 4) {
						goods.setGoods_url5(arrary.get(4));
					} else if (i == 5) {
						goods.setGoods_url6(arrary.get(5));
					} else if (i == 6) {
						goods.setGoods_url7(arrary.get(6));
					} else if (i == 7) {
						goods.setGoods_url8(arrary.get(7));
					} else if (i == 8) {
						goods.setGoods_url9(arrary.get(8));
					}
				}
			}
			}
			System.out.println("第一次上传：" + arrary + "长度：" + arrary.size());
			upload(file, arrary);
			goods.setUser_id(user.getUser_id());
			goods.setGoods("其它");
			goods.setDate(nowdata);
			goodsService.addGoods(goods);
			model.addAttribute("user", user);
			return "index-2";
		}
} 


